package com.benben.springSecurity.service.impl;

import com.benben.springSecurity.dao.IUserDao;
import com.benben.springSecurity.entity.User;
import com.benben.springSecurity.service.IUserService;
import com.sun.xml.bind.v2.model.core.ID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao userDao;


    @Override
    public void saveUser(User user) {
        userDao.save(user);
    }

    @Override
    public User findUserById(String idStr) {
//        return userDao.findById((ID)idStr);
        return null;
    }


    @Override
    public User findUserByName(String name) {

        List<User> userList = userDao.findByName(name);
        if(userList != null && userList.size()!=0){
            return userList.get(0);
        }
        return null;
    }
}
